

function addSensorbitCod(Blockly) {




    //LCD1602 初始化
   Blockly.Python.microbit_lcdinit = function(block) {
    var dropdown_lcd1602Address = Blockly.Python.valueToCode(this, 'microbit_lcdinits', Blockly.Python.ORDER_ATOMIC);
    // var dropdown_lcd1602Address =  Blockly.Python.valueToCode(this, 'microbit_lcdinits', Blockly.Python.ORDER_ATOMIC); 
    
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_lcd1602'] = 'from monitor import lcd1602';
    return 'lcd1602.init('+ dropdown_lcd1602Address +')\n';
  }

   //LCD1602 清屏
   Blockly.Python.microbit_lcdClear = function(block) {
    return 'lcd1602.clear()\n';
  }

    //LCD1602 打开关闭显示屏
    Blockly.Python.microbit_lcdScreen = function(block) {
      var dropdown_lcdScreen = this.getFieldValue('lcdScreen');
      return 'lcd1602.'+ dropdown_lcdScreen +'\n';
    }
  
     //LCD1602 打开关闭背光
     Blockly.Python.microbit_lcdBackLight = function(block) {
      var dropdown_lcdBackLight = this.getFieldValue('lcdBackLight');
      return 'lcd1602.backlight_'+ dropdown_lcdBackLight +'\n';
    }
  
    //LCD1602 光标移动
    Blockly.Python.microbit_lcdShift = function(block) {
      var dropdown_lcdShift = this.getFieldValue('lcdShift');
      return 'lcd1602.shift_'+ dropdown_lcdShift +'\n';
    }

    //LCD1602 显示
    Blockly.Python.microbit_lcdposition = function(block) {
      var dropdown_lcd1602Row =  Blockly.Python.valueToCode(this, 'row', Blockly.Python.ORDER_ATOMIC); 
      var dropdown_lcd1602Col =  Blockly.Python.valueToCode(this, 'col', Blockly.Python.ORDER_ATOMIC); 
                                    // Blockly.Python.valueToCode(this, 'initAddress', Blockly.Python.ORDER_ATOMIC);
      var dropdown_lcd1602lcdStr =  Blockly.Python.valueToCode(this, 'lcdStr', Blockly.Python.ORDER_ATOMIC); 
      dropdown_lcd1602lcdStr = dropdown_lcd1602lcdStr.replace(/'/g,"");
      return 'lcd1602.show_string('+dropdown_lcd1602lcdStr+', ' + dropdown_lcd1602Col + ', ' + dropdown_lcd1602Row + ' - 1)\n';
    }
    return Blockly;
}

module.exports = addSensorbitCod;

